package demo.day03

import java.lang.Exception
import java.lang.IllegalArgumentException

// 34 Kotlin语法中异常处理与自定义异常的特点
fun main() {
    try {
        var info: String? = null
        // 自定义异常
//        checkException(info)
        println(info!!.length)
    } catch (e: Exception) {
        println(e.message)
    }
}

private fun checkException(info: String?) {
    info?: throw CustomException()
}


class CustomException : IllegalArgumentException("空指针了，check一下代码")